
#include "BaseValidator.hpp"
#include "parser.hpp"

BaseValidator::BaseValidator(){}

BaseValidator::~BaseValidator(){}

void BaseValidator::validate()
{
	std::string field;
	int lineCount 	= 1;
	int fieldAmount = 0;

	while(this->parser.nextLine())
	{
		fieldAmount = this->parser.getNumberOfFields();
		this->validateNumberOfFields(lineCount,fieldAmount);

		for(int fieldNumber = 1; fieldNumber <= fieldAmount; fieldNumber++)
		{
			this->parser.getField(fieldNumber,field);
			this->validateField(lineCount,fieldNumber,field);
			field.clear();
		}
		this->validateElementAdding(lineCount);
		lineCount++;
	}
}

void BaseValidator::setParser(std::string &file_parse, Logger *log)
{
	this->parser.create(file_parse,log);
}
